<?php
/**
 * 文章页面
 */

class DocsController extends Controller {
    private $_model;
    public $layout = 'docs';

    public function actionIndex() {
        $model = $this->loadModel();
        $this->render('index', array(
            'model' => $model,
            'node_name' => $model->node->name
        ));
    }

    /**
     * Returns the data model based on the primary key given in the GET variable.
     * If the data model is not found, an HTTP exception will be raised.
     */
    public function loadModel() {
        if ($this->_model === null) {
            if (isset($_GET['node'])) {
                $this->_model = Article::model()->find('node_id = ' . $_GET['node']);
            }
            if ($this->_model === null) {
                throw new CHttpException(404, Yii::t('frontend', 'The requested page does not exist.'));
            }
        }
        return $this->_model;
    }
    
}
